# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Fabio Ribeiro <fabiorphp@gmail.com>
pkgname=rabbitmq-c
pkgver=0.14.0
pkgrel=0
pkgdesc="RabbitMQ C client"
url="https://github.com/alanxz/rabbitmq-c"
arch="all"
license="MIT"
depends_dev="popt-dev"
makedepends="$depends_dev openssl-dev>3 cmake xmlto doxygen samurai"
subpackages="$pkgname-utils $pkgname-doc::noarch $pkgname-static $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/alanxz/rabbitmq-c/archive/v$pkgver.tar.gz"

# secfixes:
#   0.14.0-r0:
#     - CVE-2023-35789

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_STATIC_LIBS=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DENABLE_SSL_SUPPORT=ON \
		-DBUILD_TOOLS=ON \
		-DBUILD_TOOLS_DOCS=ON
	cmake --build build
}

check() {
	cd build
	ctest -E basic
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

utils() {
	pkgdesc="$pkgdesc (command line utilities)"

	amove usr/bin
}

sha512sums="
18cb429bcfa457e359128bf458c8b9f60b1c929a8ca3a8206f40d6390d7d4c6f4c5140eb7e9ab7b401d035fc48324cbe963d058100ab65ef3faba59e7f95607e  rabbitmq-c-0.14.0.tar.gz
"
